package com.bzframework.socket.mock.provider;

import com.bzframework.socket.sse.MessagingRequest;
import com.bzframework.socket.sse.provider.SubscriptionProvider;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;

import java.time.Duration;
import java.util.Collections;
import java.util.List;

/**
 * mock provider
 */
@Component
public class MockProvider implements SubscriptionProvider {

    @Override
    public String id() {
        return "mock-provider";
    }

    @Override
    public String name() {
        return "mock-provider";
    }

    @Override
    public List<String> getTopicPattern() {
        return Collections.singletonList("/mock");
    }

    @Override
    public Flux<?> subscribe(MessagingRequest request) {
        return Flux.interval(Duration.ofSeconds(1))
                   .map(i -> "mock-provider start:" + i);
    }
}
